//
//  SystemViewController.m
//  sentorise
//
//  Created by admin on 2025/8/22.
//

#import "SystemViewController.h"
#import "GuideViewController.h"
#import "DAConfig.h"
#import "NSBundle+DAUtils.h"

@interface SystemViewController ()

@property (weak, nonatomic) IBOutlet UILabel *lngLabel;
@property (weak, nonatomic) IBOutlet UILabel *moreSetLabel;
@property (weak, nonatomic) IBOutlet UILabel *lngTitleLabel;
@property (weak, nonatomic) IBOutlet UILabel *guideTitleLabel;

@end

@implementation SystemViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.moreSetLabel.text = NSLocalizedString(@"More Setting", nil);
    self.lngTitleLabel.text = NSLocalizedString(@"Language", nil);
    self.guideTitleLabel.text = NSLocalizedString(@"User Guide", nil);
    self.lngLabel.text = NSBundle.isChineseLanguage ? @"中文" : [NSBundle.currentLanguage hasPrefix:@"de"] ? @"German" : [NSBundle.currentLanguage hasPrefix:@"fr"] ? @"Französisch" : @"English";
}

- (IBAction)actionLng:(id)sender {
    UIAlertController *sheet = [UIAlertController alertControllerWithTitle:nil message:NSLocalizedString(@"Change Language", nil) preferredStyle:UIAlertControllerStyleActionSheet];
//    [sheet addAction:[UIAlertAction actionWithTitle:@"中文" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//        DAConfig.userLanguage = @"zh-Hans";
//        self.lngLabel.text = @"中文";
//        [[NSNotificationCenter defaultCenter] postNotificationName:@"ChangedLanguageNotification" object:nil];
//    }]];
    [sheet addAction:[UIAlertAction actionWithTitle:@"English" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        DAConfig.userLanguage = @"en";
        self.lngLabel.text = @"English";
        [[NSNotificationCenter defaultCenter] postNotificationName:@"ChangedLanguageNotification" object:nil];
    }]];
    [sheet addAction:[UIAlertAction actionWithTitle:@"German" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        DAConfig.userLanguage = @"de";
        self.lngLabel.text = @"German";
        [[NSNotificationCenter defaultCenter] postNotificationName:@"ChangedLanguageNotification" object:nil];
    }]];
    [sheet addAction:[UIAlertAction actionWithTitle:@"Französisch" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        DAConfig.userLanguage = @"fr";
        self.lngLabel.text = @"Französisch";
        [[NSNotificationCenter defaultCenter] postNotificationName:@"ChangedLanguageNotification" object:nil];
    }]];
    [sheet addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil) style:UIAlertActionStyleCancel handler:nil]];
    [self presentViewController:sheet animated:YES completion:nil];
}

- (IBAction)actionGuide:(id)sender {
    GuideViewController *vc = [[GuideViewController alloc] initWithNibName:@"GuideViewController" bundle:nil];
    [self.nv pushViewController:vc animated:YES];
}


@end
